// 测试插件

string author = "Live";
string pluginName = "Plugin_Test 插件测试";
string version = "1.2";

// 是否疯狂
bool test_Enrage = false;
// 是否冻结
bool test_freeze = false;
// 是否上帝
bool isGod = false;
// 僵尸速度
bool test_zombiespeed = false;
// 无限子弹
bool test_infiniteAmmo = false;
// 复活插件
bool test_resurrection = true;
// 僵尸插件
bool test_zombieSettings = true;
// 显示僵尸速度
bool test_checkZS = false;
// 无限体力
bool test_infiniteStamina = false;

// 插件初始化
void OnPluginInit()
{
    // 设置插件信息
    PluginData::SetAuthor(author);
    PluginData::SetName(pluginName);
    PluginData::SetVersion(version);

    // 提示
    ThePresident.InfoFeed("插件:"+pluginName+"| 版本:"+version+"| 作者:"+author,false);

    Events::Player::PlayerSay.Hook( @PlayerSay );
    Events::Player::OnMenuExecuted.Hook( @OnMenuExecuted );
    Events::Infected::OnInfectedSpawned.Hook( @OnInfectedSpawned );
}

HookReturnCode OnInfectedSpawned(Infected@ pInfected)   
{
    if( test_Enrage )
        pInfected.Enrage();
    if (test_zombiespeed)
        pInfected.SetAnimationSet(10);
    if( test_checkZS )
        Chat.PrintToChat(all,"生成的僵尸速度为："+pInfected.GetAnimationSet());
	return HOOK_CONTINUE;
}

HookReturnCode PlayerSay(CTerrorPlayer@ pPlayer, CASCommand@ pArgs){
    if ( AdminSystem.AdminExist(pPlayer) ){
        string arg1 = pArgs.Arg( 1 );
        if ( Utils.StrEql( arg1, "!t" ) ){
            BaseMenu( pPlayer );
        }else if( Utils.StrEql( arg1, "!g" ) ){
            CASConVarRef@  god = ConVar::Find( "god" );
            if(god is null) return HOOK_HANDLED;
            if(isGod){
                god.SetValue("0");
                Chat.PrintToChat( pPlayer,"{hotpink}无敌已关闭");
            }else{
                god.SetValue("1");
                Chat.PrintToChat( pPlayer,"{hotpink}无敌已开启");
            }
            isGod = !isGod;
        }
    }
    return HOOK_CONTINUE;
}

HookReturnCode OnMenuExecuted(CTerrorPlayer@ pPlayer, const string &in szID, int &in iValue){

    if( szID == "test_BaseMenu" ){
        switch( iValue ){
            case 1:
                test_Weapon(pPlayer);
                break;
            case 2:
                test_Zombie(pPlayer);
                break;
            case 3:
                test_Map(pPlayer);
                break;
            case 4:
                test_prop(pPlayer);
                break;
            case 5:
                test_plugin(pPlayer);
                break;
            case 6:
                test_other(pPlayer);
                break;
        }
    }else if( szID == "test_Weapon" ){
        switch( iValue ){
            case 1:
				pPlayer.GiveWeapon("firstaid");
				break;
			case 2:
				pPlayer.GiveWeapon("Autoshotgun");
				break;
			case 3:
				pPlayer.GiveWeapon("ar15");
				break;
			case 4:
				pPlayer.GiveWeapon("handcannon");
				break;
			case 5:
				pPlayer.GiveWeapon("grenadelauncher");
				break;
            case 6:
                pPlayer.GiveWeapon("ammo");
                break;
            case 7:
                pPlayer.GiveWeapon("grenade");
                break;
            case 8:
                BaseMenu( pPlayer );
                break;
            case 9:
                test_Weapon2(pPlayer);
                break;
        }
    }else if(szID == "test_Weapon2"){
        switch( iValue ){
            case 1:
                {
                    CBaseEntity@ Weapon = pPlayer.GetCurrentWeapon();
                    Chat.PrintToChat(pPlayer,"{hotpink}当前武器名："+Weapon.GetClassname());
                }
                break;
            case 2:
                {
                    CASConVarRef@ infiniteAmmo= ConVar::Find( "sv_infinite_collected_ammo" );
                    if( test_infiniteAmmo ){
                        infiniteAmmo.SetValue("0");
                        Chat.PrintToChat(pPlayer,"{hotpink}无限子弹关闭");
                    }else{
                        infiniteAmmo.SetValue("1");
                        Chat.PrintToChat(pPlayer,"{hotpink}无限子弹开启");
                    }
                    test_infiniteAmmo = ! test_infiniteAmmo;
                }
                break;
            case 3:
                pPlayer.GiveWeapon("fingergun");
                break;
            case 4:
                pPlayer.GiveWeapon("flamethrower");
                break;
            case 8:
                test_Weapon( pPlayer );
                break;
        }
    }else if(szID == "test_Zombie"){
        switch( iValue ){
            case 1:
                Chat.PrintToChat( all,"{hotpink}当前世界僵尸数量:"+ Utils.CollectInfected().length());
                break;
            case 2:
                if( ThePresident.IsHordeMode() ){
                    ThePresident.StopHordeMode();
                    Chat.PrintToChat( all,"{hotpink}Horde模式已关闭" );                    
                }else{
                    ThePresident.BeginHordeMode();
                    Chat.PrintToChat( all,"{hotpink}Horde模式已启动（全局锁人）" );
                }   
                break;
            case 3:
                if(not test_Enrage){
                    test_Enrage = true;
                    Chat.PrintToChat( all,"{hotpink}狂暴已开启（实测无效）" );
                }else{
                    test_Enrage = false;
                    Chat.PrintToChat( all,"{hotpink}狂暴已关闭" );
                }
                break;
            case 4:
                ThePresident.SetSpawnConstantFlags(ZSF_FORCED_AREA);
                ThePresident.SetSpawnZombiesConstant(100);
                Chat.PrintToChat( all,"{hotpink}僵尸恒定数量已设定为100" );
                break;
            case 5:
                ThePresident.SetSpawnConstantFlags(ZSF_FORCED_AREA);
                ThePresident.SpawnZombies(50);
                Chat.PrintToChat( all,"{hotpink}已生成50只僵尸" );
                break;
            case 6:
                ThePresident.CleanupNonVisibleZombies();
                Chat.PrintToChat( all,"{hotpink}已清除所有僵尸" );
                break;
            case 7:
                test_freeze = !test_freeze;
                ThePresident.FreezeAllZombies(test_freeze);
                Chat.PrintToChat( all,"{hotpink}已冻结/解冻所有僵尸" );
                break;
            case 8:
                BaseMenu( pPlayer );
                break;
            case 9:
                test_Zombie2(pPlayer);
                break;
        }
    }else if( szID == "test_Zombie2" ){
        switch( iValue ){
            case 1:
                ThePresident.FindPossibleAttackTarget(null);
                Chat.PrintToChat( all,"{hotpink}所有僵尸开始主动找人(实测无效)" );
                break;
            case 2:
                test_zombiespeed = !test_zombiespeed;
                if(test_zombiespeed){
                    Chat.PrintToChat( all,"{hotpink}已开启跑尸（10）" );
                }else{
                    Chat.PrintToChat( all,"{hotpink}已关闭跑尸" );
                }
                break;
            case 3:
                ThePresident.SetSpawnConstantFlags(ZSF_FORCED_AREA);
                ThePresident.SpawnZombiesForce(50);
                Chat.PrintToChat( all,"{hotpink}强行生成50只僵尸" );
                break;
            case 4:
                Chat.PrintToChat( all,"{hotpink}显示/关闭生成的僵尸速度" );
                test_checkZS = ! test_checkZS;
                break;
            case 5:
                ThePresident.SetSpawnConstantFlags(ZSF_FORCED_AREA);
                ThePresident.SpawnZombiesConstant(20);
                Chat.PrintToChat( all,"{hotpink}设定恒增加20丧尸" );
                break;
            case 8:
                test_Zombie( pPlayer );
                break;
        }
    }else if( szID == "test_Map" ){
        switch( iValue ){
            case 1:
                Chat.PrintToChat( all,"{hotpink}当前地图类型为"+ThePresident.GetGameModeType() );
                Chat.PrintToChat( all,"{hotpink}地图类型参考|CT_DEV|"+CT_DEV+"|CT_OBJECTIVE|"+CT_OBJECTIVE+"|CT_EXTRACTION|"+CT_EXTRACTION+"|CT_FLATLINE|"+CT_FLATLINE+"|CT_HUNTED|"+CT_HUNTED);
                break;
            case 8:
                BaseMenu( pPlayer );
                break;
        }
    }else if( szID == "test_prop" ){
        switch( iValue ){
            case 1:
                pPlayer.GiveWeapon("key");
                break;
            case 2:
                pPlayer.GiveWeapon("keycard");
                break;
            case 3:
                pPlayer.GiveWeapon("boltcutter");
                break;
            case 4:
                pPlayer.GiveWeapon("torch");
                break;
            case 5:
                pPlayer.GiveWeapon("plight");
                break;
            case 6:
                pPlayer.GiveWeapon("extinguisher");
                break;
            case 8:
                BaseMenu(pPlayer);
                break;
        }
    }else if( szID == "test_plugin" ){
        switch( iValue ){
            case 1:
                if (test_resurrection){
                    Engine.RunConsoleCommand( "as_unloadplugin myas/Delayed_Resurrection.as" );
                    Chat.PrintToChat( all,"{hotpink}已暂时卸载复活插件" );
                }else{
                    Engine.RunConsoleCommand( "as_loadplugin myas/Delayed_Resurrection.as" );
                    Chat.PrintToChat( all,"{hotpink}已加载复活插件" );
                }
                test_resurrection = ! test_resurrection;
                break;
            case 2:
                if( test_zombieSettings ){
                    Engine.RunConsoleCommand( "as_unloadplugin myas/Zombie_Settings.as" );
                    Chat.PrintToChat( all,"{hotpink}已暂时卸载僵尸插件（头套）" );
                }else{
                    Engine.RunConsoleCommand( "as_loadplugin myas/Zombie_Settings.as" );
                    Chat.PrintToChat( all,"{hotpink}已加载僵尸插件" );
                }
                test_zombieSettings = ! test_zombieSettings;
                break;
            case 8:
                BaseMenu(pPlayer);
                break;
        }
    }else if(szID == "test_other"){
        switch( iValue ){
            case 1:
                {
                    CASConVarRef@ infiniteStamina= ConVar::Find( "sv_infinite_stamina" );
                    if( test_infiniteStamina ){
                        infiniteStamina.SetValue("0");
                        Chat.PrintToChat( all,"{hotpink}无限体力关闭" );
                    }else{
                        infiniteStamina.SetValue("1");
                        Chat.PrintToChat( all,"{hotpink}无限体力开启" );
                    }
                    test_infiniteStamina = ! test_infiniteStamina;
                }
                break;
            case 8:
                BaseMenu(pPlayer);
                break;
        }
    }
    return HOOK_CONTINUE;
}


void BaseMenu(CTerrorPlayer@ pPlayer){
    if ( pPlayer is null ) return;
    Menu pMenu;
	pMenu.SetID( "test_BaseMenu" );
	pMenu.SetTitle( "测试菜单" );
    pMenu.AddItem( "武器测试" );
    pMenu.AddItem( "僵尸测试" );
    pMenu.AddItem( "地图测试" );
    pMenu.AddItem( "道具测试" );
    pMenu.AddItem( "插件测试" );
    pMenu.AddItem( "其它" );
	pMenu.Display( pPlayer, -1 );
}


void test_Weapon(CTerrorPlayer@ pPlayer){
    if( pPlayer is null ) return;
    Menu pMenu;
	pMenu.SetID( "test_Weapon" );
	pMenu.SetTitle( "武器测试" );
    pMenu.AddItem( "医疗包" );
	pMenu.AddItem( "连喷" );
	pMenu.AddItem( "m4" );  
	pMenu.AddItem( "沙鹰" );
	pMenu.AddItem( "榴弹枪" );
    pMenu.AddItem( "添加子弹" );
    pMenu.AddItem( "手雷" );
    pMenu.SetBack( true );
    pMenu.SetNext( true );
    pMenu.Display( pPlayer, -1 );
}

void test_Weapon2(CTerrorPlayer@ pPlayer){
    if( pPlayer is null ) return;
    Menu pMenu;
	pMenu.SetID( "test_Weapon2" );
	pMenu.SetTitle( "武器测试" );
    pMenu.AddItem( "获取当前武器类名" );
    pMenu.AddItem( "无限子弹" );
    pMenu.AddItem( "秒杀手枪" );
    pMenu.AddItem( "火焰喷射器" );
    pMenu.SetBack( true );
    pMenu.Display( pPlayer, -1 );
}

void test_Zombie(CTerrorPlayer@ pPlayer){
    if( pPlayer is null ) return;   
    Menu pMenu;
	pMenu.SetID( "test_Zombie" );
	pMenu.SetTitle( "僵尸测试" );
    pMenu.AddItem( "当前僵尸数量" );
    pMenu.AddItem( "Horde模式" );
    pMenu.AddItem( "僵尸狂暴（生成后）" );
    pMenu.AddItem( "设置世界恒定僵尸数量" );
    pMenu.AddItem( "生成50只僵尸" );
    pMenu.AddItem( "清除所有不可见僵尸" );
    pMenu.AddItem( "冻结所有僵尸" );
    pMenu.SetNext( true );
    pMenu.SetBack( true );
    pMenu.Display( pPlayer, -1 );
}

void test_Zombie2(CTerrorPlayer@ pPlayer){
    if( pPlayer is null ) return;   
    Menu pMenu;
	pMenu.SetID( "test_Zombie2" );
	pMenu.SetTitle( "僵尸测试" );
    pMenu.AddItem( "所有僵尸找人" );
    pMenu.AddItem( "设置跑尸" );
    pMenu.AddItem( "强行生成50丧尸" );
    pMenu.AddItem( "显示生成僵尸速度" );
    pMenu.AddItem( "设定恒增加僵尸数" );
    pMenu.SetBack( true );
    pMenu.Display( pPlayer, -1 );
}

void test_Map(CTerrorPlayer@ pPlayer){
    if( pPlayer is null ) return;   
    Menu pMenu;
	pMenu.SetID( "test_Map" );
    pMenu.SetTitle( "地图测试" );
    pMenu.AddItem( "当前地图类型" );
    pMenu.SetBack( true );
    pMenu.Display( pPlayer, -1 );
}

void test_prop(CTerrorPlayer@ pPlayer){
    if( pPlayer is null ) return;   
    Menu pMenu;
	pMenu.SetID( "test_prop" );
    pMenu.SetTitle( "道具测试" );
    pMenu.AddItem( "钥匙" );
    pMenu.AddItem( "卡片" );
    pMenu.AddItem( "钳子" );
    pMenu.AddItem( "喷灯" );
    pMenu.AddItem( "便携式手电" );
    pMenu.AddItem( "灭火器" );
    pMenu.SetBack( true );
    pMenu.Display( pPlayer, -1 );
}

void test_plugin(CTerrorPlayer@ pPlayer){
    if( pPlayer is null ) return;   
    Menu pMenu;
	pMenu.SetID( "test_plugin" );
    pMenu.SetTitle( "插件测试" );
    pMenu.AddItem( "复活插件" );
    pMenu.AddItem( "僵尸插件" );
    pMenu.SetBack( true );
    pMenu.Display( pPlayer, -1 );                       
}

void test_other(CTerrorPlayer@ pPlayer){
    if( pPlayer is null ) return;   
    Menu pMenu;
	pMenu.SetID( "test_other" );
    pMenu.SetTitle( "其它测试" );
    pMenu.AddItem( "无限体力" );
    pMenu.SetBack( true );
    pMenu.Display( pPlayer, -1 );                       
}